<template>
  <div class="approval-detail">
    <!-- 顶部标题 -->
    <div class="header">
      <h1>蓝考管理 / 审批详情</h1>
    </div>

    <!-- 审批状态标签 -->
    <div :class="['status-tag', type]">
      {{ type === 'approved' ? '报名成功' : '报名失败' }}
      <div class="time">报名时间：2023/9/13 00:00:00</div>
    </div>

    <!-- 报名表单 -->
    <div class="form-container">
      <h2>四川大学锦江学院研究生招生考试监考人员报名表</h2>

      <div class="form-section">
        <div class="form-row">
          <div class="form-item">
            <label>姓名：</label>
            <div class="form-value">{{ applicant.name }}</div>
          </div>
          <div class="form-item">
            <label>所在单位：</label>
            <div class="form-value">{{ applicant.department }}</div>
          </div>
        </div>

        <div class="form-row">
          <div class="form-item">
            <label>性别：</label>
            <div class="form-value">{{ applicant.gender }}</div>
          </div>
          <div class="form-item">
            <label>工号：</label>
            <div class="form-value">{{ applicant.workId }}</div>
          </div>
        </div>

        <div class="form-row">
          <div class="form-item">
            <label>学历：</label>
            <div class="form-value">{{ applicant.education }}</div>
          </div>
          <div class="form-item">
            <label>联系电话：</label>
            <div class="form-value">{{ applicant.phone }}</div>
          </div>
        </div>

        <div class="form-row">
          <div class="form-item">
            <label>填报日期：</label>
            <div class="form-value">{{ applicant.applyDate }}</div>
          </div>
          <div class="form-item">
            <label>出生年月：</label>
            <div class="form-value">{{ applicant.birthDate }}</div>
          </div>
        </div>
      </div>

      <!-- 照片上传 -->
      <div class="photo-section">
        <h3>上传电子照片：</h3>
        <div class="photo-container">
          <div class="photo-placeholder">
            <div class="plus-icon">+</div>
            <div class="upload-text">上传</div>
          </div>
          <div class="photo-requirements">
            <p>接收上传分辨率未450x300的扫描图片</p>
            <p>仅支持上传JPG、PNG格式图片，限制1张，文件大小10M以下</p>
          </div>
        </div>
      </div>

      <!-- 监考校区 -->
      <div class="campus-section">
        <h3>监考校区：</h3>
        <div class="campus-options">
          <div v-for="(campus, index) in campuses" :key="index" class="campus-option">
            <input type="checkbox" :id="'campus'+index" :checked="campus.checked" disabled>
            <label :for="'campus'+index">{{ campus.name }}</label>
          </div>
        </div>
      </div>

      <!-- 申请人承诺 -->
      <div class="commitment-section">
        <h3>申请人承诺：</h3>
        <div class="commitment-text">
          本人自愿参加研究生入学考试监考工作，认真学习监考工作要求，严格遵守《国家教育考试违规处理办法》和考场纪律，认真履行监考职责，维护考场秩序，确保考试工作顺利完成。
        </div>
        <div class="signature">
          <label>本人自愿参加：</label>
          <div class="signature-value">{{ applicant.name }}</div>
        </div>
      </div>
    </div>

    <!-- 审批历史记录 -->
    <div class="history-section">
      <h2>历史记录</h2>
      <div class="history-container">
        <div v-for="(record, index) in historyRecords" :key="index" class="history-item">
          <div class="record-header">
            <div class="record-stage">{{ record.stage }}</div>
            <div class="record-time">{{ record.time }}</div>
          </div>
          <div class="record-details">
            <div class="record-row">
              <span>{{ record.role }}：</span>
              <span>{{ record.reviewer }} ({{ record.workId }})</span>
            </div>
            <div v-if="record.result" class="record-row">
              <span>审批结果：</span>
              <span :class="['result', record.resultClass]">{{ record.result }}</span>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 操作按钮 -->
    <div class="action-buttons">
      <button class="back-button" @click="goBack">返回</button>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, computed, onMounted } from 'vue';
import { useRoute, useRouter } from 'vue-router';

const route = useRoute();
const router = useRouter();

// 获取路由参数
const type = computed(() => route.params.type as string);
const id = computed(() => route.params.id as string);

// 申请人信息
const applicant = ref({
  name: '张三',
  department: '计算机学院',
  gender: '男',
  workId: '10001',
  education: '博士',
  phone: '13800138000',
  applyDate: '2023-09-15',
  birthDate: '1985-01-01'
});

// 校区选项
const campuses = ref([
  { id: 'jj', name: '锦江校区', checked: true },
  { id: 'other', name: '其他校区', checked: false },
  { id: 'fc', name: '服从调剂', checked: true }
]);

// 审批历史记录
const historyRecords = ref([
  {
    stage: '发起人(在职在岗教职工)',
    role: '教职工',
    reviewer: '张三',
    workId: '10001',
    time: '2023/09/19 19:02:44',
    result: '',
    resultClass: ''
  },
  {
    stage: '审批人(学院职工办主任)',
    role: '教职工',
    reviewer: '李主任',
    workId: '10002',
    time: '2023/09/20 10:15:33',
    result: '同意报名',
    resultClass: 'approved'
  },
  {
    stage: '审批人(职能部门综合办主任)',
    role: '教职工',
    reviewer: '王主任',
    workId: '10003',
    time: '2023/09/21 11:20:45',
    result: '同意报名',
    resultClass: 'approved'
  },
  {
    stage: '审批人(学院分管研究生工作副院长)',
    role: '教职工',
    reviewer: '赵院长',
    workId: '10004',
    time: '2023/09/22 14:30:22',
    result: '同意报名',
    resultClass: 'approved'
  },
  {
    stage: '审批人(研究生招生考务科科长)',
    role: '教职工',
    reviewer: '孙科长',
    workId: '10005',
    time: '2023/09/23 16:45:10',
    result: type.value === 'approved' ? '同意报名' : '不同意报名',
    resultClass: type.value === 'approved' ? 'approved' : 'rejected'
  }
]);

onMounted(() => {
  // 根据id获取申请详情数据
  console.log(`加载详情，类型：${type.value}, id: ${id.value}`);
});

// 返回上一页
const goBack = () => {
  router.go(-1);
};
</script>

<style scoped>
.approval-detail {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  font-family: 'Microsoft YaHei', sans-serif;
  color: #333;
}

.header {
  text-align: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid #1a3a6c;
}

.header h1 {
  margin: 0;
  font-size: 22px;
  color: #1a2b4b;
}

.status-tag {
  padding: 12px 20px;
  border-radius: 6px;
  margin-bottom: 25px;
  font-size: 18px;
  font-weight: bold;
  text-align: center;
  position: relative;
}

.status-tag.approved {
  background-color: #f6ffed;
  border: 1px solid #b7eb8f;
  color: #52c41a;
}

.status-tag.rejected {
  background-color: #fff2f0;
  border: 1px solid #ffccc7;
  color: #f5222d;
}

.status-tag .time {
  font-size: 14px;
  font-weight: normal;
  margin-top: 5px;
  color: #666;
}

.form-container {
  padding: 20px;
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  margin-bottom: 30px;
  background-color: #fafafa;
}

.form-container h2 {
  text-align: center;
  margin: 0 0 25px 0;
  padding-bottom: 15px;
  border-bottom: 1px solid #e8e8e8;
  color: #1a2b4b;
}

.form-section {
  margin-bottom: 20px;
}

.form-row {
  display: flex;
  margin-bottom: 15px;
}

.form-item {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 10px;
}

.form-item label {
  font-weight: bold;
  min-width: 100px;
  color: #1a2b4b;
}

.form-value {
  padding: 8px 12px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  background-color: white;
  flex-grow: 1;
}

.photo-section h3,
.campus-section h3,
.commitment-section h3 {
  color: #1a2b4b;
  margin: 20px 0 15px 0;
  padding-left: 5px;
  border-left: 3px solid #1a3a6c;
}

.photo-container {
  display: flex;
  align-items: center;
  gap: 20px;
}

.photo-placeholder {
  width: 150px;
  height: 200px;
  border: 1px dashed #d9d9d9;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: white;
  cursor: pointer;
}

.plus-icon {
  font-size: 40px;
  color: #8c8c8c;
  line-height: 1;
}

.upload-text {
  margin-top: 10px;
  color: #8c8c8c;
}

.photo-requirements {
  color: #8c8c8c;
  font-size: 14px;
}

.photo-requirements p {
  margin: 5px 0;
}

.campus-options {
  display: flex;
  gap: 30px;
}

.campus-option {
  display: flex;
  align-items: center;
}

.campus-option input {
  margin-right: 8px;
}

.commitment-text {
  background-color: #f8fafc;
  padding: 15px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
  line-height: 1.6;
  margin-bottom: 15px;
}

.signature {
  display: flex;
  align-items: center;
}

.signature label {
  font-weight: bold;
  min-width: 120px;
}

.signature-value {
  padding: 8px 12px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  background-color: white;
  flex-grow: 1;
}

.history-section {
  margin-top: 30px;
}

.history-section h2 {
  color: #1a2b4b;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid #1a3a6c;
}

.history-container {
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  background-color: #fafafa;
}

.history-item {
  padding: 15px;
  border-bottom: 1px solid #e8e8e8;
}

.history-item:last-child {
  border-bottom: none;
}

.record-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.record-stage {
  font-weight: bold;
  color: #1a2b4b;
}

.record-time {
  color: #666;
  font-size: 14px;
}

.record-row {
  display: flex;
  margin-bottom: 8px;
}

.record-row span:first-child {
  min-width: 80px;
  font-weight: bold;
}

.result {
  font-weight: bold;
}

.result.approved {
  color: #52c41a;
}

.result.rejected {
  color: #f5222d;
}

.action-buttons {
  text-align: center;
  margin-top: 30px;
}

.back-button {
  padding: 10px 35px;
  background-color: #1a3a6c;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.back-button:hover {
  background-color: #0d2a56;
}
</style>